﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using YanZhiwei.DotNet2.Utilities.Tests.Model;
namespace YanZhiwei.DotNet2.Utilities.Base.Tests
{
    [TestClass()]
    public class PagerListTests
    {
        /// <summary>
        /// 分页集合
        /// </summary>
        private PagerList<Person> _list;

        /// <summary>
        /// 测试初始化
        /// </summary>
        [TestInitialize]
        public void TestInit()
        {
            _list = new PagerList<Person>(1, 5, 10);
            for (byte i = 0; i < 10; i++)
            {
                _list.Add(new Person() { Name = "A", Age = (byte)(15 + i) });
            }
        }

        /// <summary>
        /// 元素个数
        /// </summary>
        [TestMethod]
        public void TestCount()
        {
            Assert.AreEqual(10, _list.Count);
        }

        /// <summary>
        /// 用索引获取元素
        /// </summary>
        [TestMethod]
        public void TestIndex()
        {
            Assert.AreEqual(16, _list[1].Age);
        }

        ///// <summary>
        ///// 转换类型
        ///// </summary>
        //[TestMethod]
        //public void TestConvert()
        //{
        //    var result = _list.Convert(t => t.Age <= 18);
        //    Assert.AreEqual(2, result.Count);
        //    Assert.AreEqual(1, result.Page);
        //    Assert.AreEqual(2, result.PageSize);
        //    Assert.AreEqual(2, result.TotalCount);
        //    Assert.AreEqual(1, result.PageCount);
        //}

    }
}
